package com.wx.app.ui.activity;

import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.widget.Button;

import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.example.administrator.newemptyapplication.R;
import com.wx.app.mylib.app.BaseActivity;
import com.wx.app.mylib.view.ProgressBarHor;
import com.wx.app.mylib.view.ProgressBarRound;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class TestActivity extends BaseActivity {

    @BindView(R.id.btn_test_add)
    Button btnAdd;
    @BindView(R.id.btn_test_delete)
    Button btnDelete;
    @BindView(R.id.btn_round)
    Button btnRound;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        ButterKnife.bind(this);
    }

    @OnClick(R.id.btn_test_add)
    void Add() {
        MaterialDialog materialDialog = new MaterialDialog.Builder(this)
                .title("提示对话框")
                .content("修复了**BUG,优化了**界面。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。")
                .onPositive(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        showToast("点击确定！");
                    }
                })
                .positiveText("确定")
                .onNegative(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        showToast("点击取消！");
                    }
                })
                .negativeText("取消")
                .show();

        materialDialog.setIcon(R.drawable.ic_default_adimage);
    }

    @OnClick(R.id.btn_test_delete)
    void delete() {
        showToast("加载进度条！");

        final ProgressBarHor progressBarHor = new ProgressBarHor(mActivity,R.style.progress_dialog);
        progressBarHor.setCanceledOnTouchOutside(false);
        progressBarHor.show();

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                progressBarHor.cancel();
            }
        }, 3000);
    }

    @OnClick(R.id.btn_round)
    void showRound() {
        showToast("加载进度条！");
        final ProgressBarRound progressBarRound = new ProgressBarRound(mActivity,R.style.progress_dialog);
        progressBarRound.setCanceledOnTouchOutside(false);
        progressBarRound.show();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                progressBarRound.cancel();
            }
        }, 3000);
    }
}
